//
//  TitleTool.m
//  OnionHome
//
//  Created by fengjie on 2019/10/17.
//  Copyright © 2019 FengJie. All rights reserved.
//

#import "TitleTool.h"

@implementation TitleTool
/// 设置动态列表头部文字
/// @param title 显示内容
/// @param titleLabel 显示的label
+(void)setDynamicTitle:(NSString *)title Label:(UILabel *)titleLabel{
    if (!StrValid(title)) {
        title = @"今天晚上做了法式薄煎饼，简单容易上手，老人孩子都喜欢吃，美味又健康，在家....";
    }
    NSMutableParagraphStyle * paragstrye = [[NSMutableParagraphStyle alloc] init];
    paragstrye.lineSpacing = 5;
    
    NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:title attributes: @{NSFontAttributeName: PingFangSC_Medium(18),NSForegroundColorAttributeName: UIColorFromRGB(0x273323),NSParagraphStyleAttributeName:paragstrye}];

    titleLabel.attributedText = string;
    titleLabel.alpha = 1.0;
}
+(void)setTwoCommenUserName:(NSString *)name contTitle:(NSString *)contTitle Label:(UILabel *)label{
    
    if (!StrValid(contTitle)) {
        contTitle = @"如果你无法简洁的表达你的想法，那只说明你还不够了解它。真理惟一可靠的标准就是永远自相符合。";
    }
    if (!StrValid(name)) {
        name = @"孤独的恒星";
    }
    
    NSMutableParagraphStyle * paragstrye = [[NSMutableParagraphStyle alloc] init];
    paragstrye.lineSpacing = 5;
    
    NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:name attributes: @{NSFontAttributeName: SYSTEMFONT(14),NSForegroundColorAttributeName: UIColorFromRGB(0x2B77EC),NSParagraphStyleAttributeName:paragstrye}];
    
    [string makeAttributeStringAdd:[NSString stringWithFormat:@"：%@",contTitle] Attribute:^(NSMutableDictionary * _Nonnull attributes) {
        attributes.Font(14).Color(UIColorFromRGB(0x363647));
        [attributes setValue:paragstrye forKey:NSParagraphStyleAttributeName];
    }];

    label.attributedText = string;
    label.alpha = 1.0;
}
+(NSMutableAttributedString *)getAttributeStringLineSpacing:(CGFloat)lineSpacing title:(NSString *)title titleColor:(UIColor *)color titleFont:(UIFont *)font{
    
    if (!color) {
        color = UIColorFromRGB(0x273323);
    }
    if (!font) {
        font = PingFangSC_Medium(18);
    }
    
    NSMutableParagraphStyle * paragstrye = [[NSMutableParagraphStyle alloc] init];
    paragstrye.lineSpacing = lineSpacing;
    
    NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:title attributes: @{NSFontAttributeName: font,NSForegroundColorAttributeName: color,NSParagraphStyleAttributeName:paragstrye}];
    
    return string;
}
@end
